package com.knight.concurrent.chapter6;

/**
 * 关闭多线程
 *
 * @author: knight
 * @Date: 2019-03-01 6:58
 */
public class ThreadCloseGraceful {

    public static void main(String[] args) {
        WorkThread workThread = new WorkThread();
        workThread.start();

        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        workThread.shutDown();

    }

    private static class WorkThread extends Thread {

        private volatile boolean start = true;

        @Override
        public void run() {
            while (start) {

            }
        }

        public void shutDown() {
            start = false;
        }
    }


}
